%% driver for ODE solver for 

clc
%clf
clear all

coarsen_factor = 2;
beta=2;
start_t=0;
end_t =2 ;
exact_solution = - log(1+ beta*end_t);
initial_value = - log(1+ beta*start_t);
tolerance = 0.000001;
num_step_fine = 256;
SF=1; % safty factor

for icoarse = 1:4
   num_step = num_step_fine / (2^(icoarse-1));
   dt = (end_t - start_t)/ num_step;
  
   c_old = initial_value;
   time = start_t;
    
   for i=1:num_step;
      
        [c_new,dt_required]= RK45(@source_stiff, c_old ,dt,tolerance,time,SF);
      time = time + dt ;
      c_old = c_new;
      
   end
   
   c_repository(icoarse)=c_old;
   error(icoarse)= abs(c_old-exact_solution);
   
    
end